#ifndef _DSWUPNPCLIENT_H
#define _DSWUPNPCLIENT_H

#include <libbase/dswbase.h>
#include <miniupnpc/miniwget.h>
#include <miniupnpc/miniupnpc.h>
#include <miniupnpc/upnpcommands.h>
#include <miniupnpc/upnperrors.h>

class CDswupnpclient : public CDswbase
{
public:
	CDswupnpclient(LPST_ENV_T pEnv);
	virtual ~CDswupnpclient();
protected:
	virtual int OnMessage(EN_MSG_TYPE nMsgType, void * pParam);
private:
	static void* cbUpnpThreadFunc(void* pParam){((CDswupnpclient*)pParam)->UpnpThreadFunc();return NULL;};
	void UpnpThreadFunc();
	bool SetRedirectAndTest(struct UPNPUrls * urls,
		struct IGDdatas * data,
		const char * iaddr,
		const char * iport,
		const char * eport,
		const char * proto,
		const char * leaseDuration,
		const char * description,
		int addAny);
	void RemovePortMap(struct UPNPUrls * urls, struct IGDdatas * data, char* pDevId);
	void ListPortMap(struct UPNPUrls * urls, struct IGDdatas * data);
private:
	pthread_t m_thread_id;
	NAT_TYPE_E m_nNatType;
	pthread_mutex_t m_nLock;
};

#endif

